#!/bin/zsh
export ROS_MASTER_URI=http://192.168.1.104:11311 #主机IP地址:11311
export ROS_IP=192.168.1.106 #IP地址

# 定义函数，用于运行uwb_imu
function launch_uwbimu {
    echo "Running uwb_imu..."
    cd /home/up/catkin_ws
    source ./devel/setup.zsh
    roslaunch nlink_parser uwb_imu.launch
}

# 在后台运行第1个launch文件
launch_uwbimu &
# 等待一段时间
sleep 5

# 定义函数，用于运行第dwe_onboard(note: when test, launch the onboard, when ctr, launch the onboard_ctrl)
function launch_dweonboard {
    echo "Running dweonboard..."
    cd /home/up/ws/dwe_multi_ws
    source ./devel/setup.zsh
    # for test
    roslaunch dwe_multi dwe_multi_onboard.launch
    # for ctrl
    # roslaunch dwe_multi dwe_multi_onboard_ctrl.launch
}

# 在后台运行launch文件
launch_dweonboard &
# 等待一段时间
sleep 5

# 定义函数，用于运行launch文件
function launch_mavros {
    echo "Running mavros..."
    cd /home/up/mavros_ws
    source ./devel/setup.zsh
    roslaunch mavros px4.launch
}
# 在后台运行launch文件
launch_mavros &
# 等待一段时间
sleep 5

# 定义函数，用于运行launch文件
function launch_px4ctrl {
    echo "Running px4ctrl..."
    cd /home/up/ws/offboard_ws
    source ./devel/setup.zsh
    roslaunch px4ctrlfsm px4ctrl_node.launch
}
# 在后台运行launch文件
launch_px4ctrl &
# 等待一段时间
sleep 5

 
# 在后台运行第三个launch文件
# launch_line_follow &
# gnome-terminal -- bash -c "source /home/zyq/zyq_shell/start_both.sh; launch_line_follow; read -p 'Press Enter to continue...'"


# source /opt/ros/noetic/setup.zsh
# source ~/.zshrc

# 启动第一个 launch 文件
# sh -c "roslaunch nlink_parser uwb_imu.launch" &
# roslaunch nlink_parser uwb_imu.launch &
# echo "uwb_imu launch success!"
# sleep 5.0s

# 启动第二个 launch 文件
# sh -c "roslaunch mavros px4.launch" &
# roslaunch mavros px4.launch &
# echo "mavros launch success!"
# sleep 5.0s

# 启动第三个 launch 文件
# sh -c "roslaunch px4ctrlfsm px4ctrl_node.launch" &
# roslaunch px4ctrlfsm px4ctrl_node.launch &
# echo "px4ctrlfsm launch success!"
# sleep 2.0s
